<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    Function.prototype.myApply = function (context) {
      var context = context || window
      context.fn = this
      //判断是否有第二个参数，有则展开
      var result = arguments[1] ? context.fn(...arguments[1]) : context.fn()
      delete context.fn
      return result
    }
  </script>
</body>

</html>